<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright (C) 2006, 2007 Jeff Epler

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-->
<html xml:lang="en" xmlns="https://www.w3.org/1999/xhtml">
  <head>
    <title>LinuxCNC "G-code" Quick Reference</title>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css"><!--
table { border: 1px solid black; border-collapse: collapse; }
table #titlerow th { border-bottom: 2px solid black; border-left: 2px solid black; text-align: center; }
table #titlerow th:first-child { border-bottom: 2px solid black; border-left: 0px; text-align: center; }
table td:first-child { border-left: 0px; }
table td { border-left: 1px solid black; padding-left: .25em; padding-right: .25em; }
table th { text-align: left; border-bottom: 1px solid black; border-top: 1px solid black; }
@media print {
@page { margin: .150in; }
html { padding: 0; margin: 0; }
body { padding: 3px; margin: 3px; }
* { font-size: 8pt }
a { text-decoration: none; color: black; }
table { width: 100%; }
}
td { background: white; color: black; }
tr.odd td { background: #d9d9d9; }
tr.head td, tr.head th { background: black; color: white; }
--></style>
</head>

<body>
<table id="ref1">
  <caption> LinuxCNC "G-code" Quick Reference </caption>
  <colgroup>
    <col id="group"/> <col id="code"/> <col id="params"/> <col id="description"/>
  </colgroup>
  <tbody>
    <tr id="titlerow"> <th>Code </th><th>Parameters </th><th>Description </th></tr>

    <tr><th>Motion</th><td colspan="2" style="border-bottom: 1px solid black">(X Y Z A B C U V W apply to all motions)</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g0">G0</a></td><td/><td>Rapid Move</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g1">G1</a></td><td/><td>Linear Move</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g2-g3">G2, G3</a></td><td>I J K or R P</td><td>Arc Move</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g4">G4</a></td><td>P</td><td>Dwell</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g5">G5</a></td><td>I J P Q</td><td>Cubic Spline</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g5.1">G5.1</a></td><td>I J</td><td>Quadratic Spline</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g5.2-g5.3">G5.2</a></td><td>P L</td><td>NURBS</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g38">G38.2 - G38.5</a></td><td/><td>Straight Probe</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g33">G33</a></td><td>K ($)</td><td>Spindle Synchronized Motion</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g33.1">G33.1</a></td><td>K ($)</td><td>Rigid Tapping</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g80">G80</a> </td><td/><td>Cancel Canned Cycle</td></tr>

    <tr><th>Canned cycles</th><td colspan="2">(X Y Z or U V W apply to canned cycles, depending on active plane)</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g70">G70</a></td><td>Q (X) (Z) (D) (E) (P)</td><td>Lathe finishing cycle</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g71-g72">G71 G72</a></td><td>Q (X) (Z) (D) (E) (P)</td><td>Lathe roughing cycle</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g73">G73</a></td><td>R L Q</td><td>Drilling Cycle, Chip Breaking</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g74">G74</a></td><td>R L (P) ($)</td><td>Left-hand Tapping Cycle, Dwell</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g76">G76</a></td><td>P Z I J R K Q H L E ($)</td><td>Threading Cycle</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g81">G81</a></td><td>R L (P)</td><td>Drilling Cycle</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g82">G82</a></td><td>R L (P)</td><td>Drilling Cycle, Dwell</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g83">G83</a></td><td>R L Q</td><td>Drilling Cycle, Peck</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g84">G84</a></td><td>R L (P) ($)</td><td>Right-hand Tapping Cycle, Dwell</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g85">G85</a></td><td>R L (P)</td><td>Boring Cycle, Feed Out</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g89">G89</a></td><td>R L (P)</td><td>Boring Cycle, Dwell, Feed Out</td></tr>

    <tr><th colspan="3">Distance Mode</th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g90-g91">G90, G91</a></td><td/><td>Distance Mode</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g90.1-g91.1">G90.1, G91.1</a></td><td/><td>Arc Distance Mode</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g7">G7</a></td><td/><td>Lathe Diameter Mode</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g8">G8</a></td><td/><td>Lathe Radius Mode</td></tr>

    <tr><th colspan="3">Feed Rate Mode </th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g93-g94-g95">G93, G94, G95</a></td><td>S ($)</td><td>Feed Rate Mode</td></tr>

    <tr><th colspan="3">Spindle Control </th></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m3-m4-m5">M3, M4, M5</a></td><td>S ($)</td><td>Spindle Control</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m19">M19</a></td><td>R Q (P) ($)</td><td>Orient Spindle</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g96-g97">G96, G97</a></td><td> S D ($)</td><td>Spindle Control Mode</td></tr>

    <tr><th colspan="3">Coolant </th></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m7-m8-m9">M7, M8, M9</a></td><td/><td>Coolant Control</td></tr>

    <tr><th colspan="3">Tool Length Offset </th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g43">G43</a> </td><td> H </td><td>Tool Length Offset</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g43.1">G43.1</a> </td><td> </td><td>Dynamic Tool Length Offset</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g43.2">G43.2</a> </td><td> H </td><td>Apply additional Tool Length Offset</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g49">G49</a> </td><td> </td><td>Cancel Tool Length Compensation</td></tr>

    <tr><th colspan="3">Stopping </th></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m0-m1">M0, M1</a></td><td/><td>Program Pause</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m2-m30">M2, M30</a></td><td> </td><td>Program End</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m60">M60</a></td><td/><td>Pallet Change Pause</td></tr>

    <tr><th colspan="3">Units </th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g20-g21">G20, G21</a></td><td> </td><td>Units (inch, mm)</td></tr>

    <tr><th>Plane Selection </th><td colspan="2">(affects G2, G3, G81…G89, G40…G42) </td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g17-g19.1">G17 - G19.1</a></td><td/><td>Plane Select</td></tr>

    <tr><th colspan="3">Cutter Radius Compensation </th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g40">G40</a></td><td/><td>Compensation Off</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g41-g42">G41,G42</a></td><td>D</td><td>Cutter Compensation</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g41.1-g42.1">G41.1, G42.1</a></td><td>D L</td><td>Dynamic Cutter Compensation</td></tr>

    <tr><th colspan="3">Path Control Mode </th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g61">G61 G61.1</a></td><td/><td>Exact Path Mode</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g61.1">G61.1</a></td><td/><td>Exact Stop Mode</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g64">G64</a></td><td>P Q</td><td>Path Blending</td></tr>

    <tr><th colspan="3">Return Mode in Canned Cycles </th></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g98-g99">G98, G99</a></td><td/><td>Canned Cycle Return Level</td></tr>

    <tr><th colspan="3">Other Modal Codes </th></tr>
    <tr><td><a href="gcode/other-code.html#sec:set-feed-rate">F</a></td><td/><td>Set Feed Rate</td></tr>
    <tr><td><a href="gcode/other-code.html#sec:set-spindle-speed">S</a></td><td>($)</td><td>Set Spindle Speed</td></tr>
    <tr><td><a href="gcode/other-code.html#sec:select-tool">T</a></td><td/><td>Select Tool</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m48-m49">M48, M49</a></td><td/><td>Speed and Feed Override Control</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m50">M50</a></td><td>P0 (off) or P1 (on)</td><td>Feed Override Control</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m51">M51</a></td><td>P0 (off) or P1 (on) ($)</td><td>Spindle Speed Override Control</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m52">M52</a></td><td>P0 (off) or P1 (on)</td><td>Adaptive Feed Control</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m53">M53</a></td><td>P0 (off) or P1 (on)</td><td>Feed Stop Control</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g54-g59.3">G54-G59.3</a></td><td/><td>Select Coordinate System</td></tr>

    <tr><th colspan="3">Flow-control Codes </th></tr>
    <tr><td><a href="gcode/o-code.html#ocode:subroutines">o sub</a></td><td/><td>Subroutines, sub/endsub call</td></tr>
    <tr><td><a href="gcode/o-code.html#ocode:looping">o while</a></td><td/><td>Looping, while/endwhile do/while</td></tr>
    <tr><td><a href="gcode/o-code.html#ocode:conditional">o if</a></td><td/><td>Conditional, if/else/endif</td></tr>
    <tr><td><a href="gcode/o-code.html#ocode:repeat">o repeat</a></td><td/><td>Repeat a loop of code</td></tr>
    <tr><td><a href="gcode/o-code.html#ocode:indirection">[]</a></td><td/><td>Indirection</td></tr>
    <tr><td><a href="gcode/o-code.html#ocode:calling-files">o call</a></td><td/><td>Call named file</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m70">M70</a></td><td/><td>Save modal state</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m71">M71</a></td><td/><td>Invalidate stored state</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m72">M72</a></td><td/><td>Restore modal state</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m73">M73</a></td><td/><td>Save and Auto-restore modal state</td></tr>

    <tr><th colspan="3">Input/Output Codes </th></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m62-m65">M62 - M65</a></td><td>P</td><td>Digital Output Control</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m66">M66</a></td><td>P E L Q</td><td>Wait on Input</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m67">M67</a></td><td>T</td><td>Analog Output, Synchronized</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m68">M68</a></td><td>T</td><td>Analog Output, Immediate</td></tr>

    <tr><th colspan="3">Non-modal Codes </th></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m6">M6</a></td><td>T</td><td>Tool Change</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m61">M61</a></td><td>Q</td><td>Set Current Tool</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g10-l0">G10 L0</a></td><td/><td>Reload Tool Table Data</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g10-l1">G10 L1</a></td><td>P Q R</td><td>Set Tool Table</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g10-l10">G10 L10</a></td><td>P</td><td>Set Tool Table</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g10-l11">G10 L11</a></td><td>P</td><td>Set Tool Table</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g10-l2">G10 L2</a></td><td>P R</td><td>Set Coordinate System</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g10-l20">G10 L20</a></td><td>P</td><td>Set Coordinate System</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g28-g28.1">G28, G28.1</a></td><td/><td>Go/Set Predefined Position</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g30-g30.1">G30, G30.1</a></td><td/><td>Go/Set Predefined Position</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g53">G53</a></td><td/><td>Move in Machine Coordinates</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g92">G52, G92</a></td><td/><td>Coordinate System Offset</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g92.1-g92.2">G92.1, G92.2</a></td><td/><td>Reset G92 Offsets</td></tr>
    <tr><td><a href="gcode/g-code.html#gcode:g92.3">G92.3</a></td><td/><td>Restore G92 Offsets</td></tr>
    <tr><td><a href="gcode/m-code.html#mcode:m100-m199">M101 - M199</a></td><td>P Q</td><td>User Defined Commands</td></tr>

    <tr><th colspan="3">Comments &amp; Messages</th></tr>
    <tr><td><a href="gcode/overview.html#gcode:comments">; (…)</a></td><td/><td>Comments</td></tr>
    <tr><td><a href="gcode/overview.html#gcode:messages">(MSG,…)</a></td><td/><td>Messages</td></tr>
    <tr><td><a href="gcode/overview.html#gcode:debug">(DEBUG,…)</a></td><td/><td>Debug Messages</td></tr>
    <tr><td><a href="gcode/overview.html#gcode:print">(PRINT,…)</a></td><td/><td>Print Messages</td></tr>

  </tbody>
</table>

<script type="text/javascript"><!--

var rows=document.evaluate('//tr', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var j=0;
for(var i=0; i<rows.snapshotLength; i++) {
    var it = rows.snapshotItem(i);
    var th = document.evaluate('th', it, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    if(th.snapshotLength) {
        it.setAttribute('class', 'head');
        j = 0;
    } else {
        if(j) it.setAttribute('class', 'odd');
        j = !j;
    }
}

function fixup_urls() {
var links=document.evaluate('//a[@href]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    for(var i=0; i<links.snapshotLength; i++) {
        var it = links.snapshotItem(i);
        it.setAttribute('href',
            "https://linuxcnc.org/docs/devel/html/" + it.getAttribute('href'));
    }
}

// In the LinuxCNC package, gcode/g-code.html is (probably) not included.  In this
// case, fix up the links to point at the online version instead of a local
// version
if(document.location.protocol == "file:") {
    try {
        var x = document.implementation.createDocument("", "", null);
        x.load("gcode/g-code.html");
        x.onerror = fixup_urls;
    } catch(err) {
        fixup_urls();
    }
}

// --></script>

</body></html>
